<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../../css/user.css" media="all" />
</head>
<body class="childrenBody" style="background: #fff">
	<form class="layui-form changePwd" id="pwd">
		<div style="margin:0 0 15px 110px;color:#f00;">新密码必须两次输入一致才能提交</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">新密码</label>
		    <div class="layui-input-block">
		    	<input type="password" name="newPwd" value="" placeholder="请输入新密码" lay-verify="required|newPwd" id="oldPwd" class="layui-input pwd">
		    </div>
		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">确认密码</label>
		    <div class="layui-input-block">
		    	<input type="password" name="newPwds" value="" placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd">
		    </div>
		</div>
		<div class="layui-form-item">
		    <div class="layui-input-block">
		    	<button class="layui-btn" type="button" lay-submit=""  lay-filter="add" lay-filter="changePwd">立即修改</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		</div>
	</form>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script src="../../js/common.js"></script>
	<script type="text/javascript" src="address.js"></script>
	<script type="text/javascript" src="user.js"></script>
	<script>
        layui.use(['laypage', 'layer', 'element', 'form'], function () {
            var laypage = layui.laypage,
                layer = layui.layer,
                form = layui.form,
                element = layui.element,
                laydate = layui.laydate,
                $ = layui.jquery;

            form.on('submit(add)', function (data) {
                var load = layer.load(2, {
                    shade: [0.6, '#fff'] //0.1透明度的白色背景
                });
                var obj = {
                    password: data.field.newPwd,
                    repassword: data.field.newPwds
                }
                var url = 'api/user/editpass';
                $.when(PUATTRBUTE.REQUESTFUN(url, obj).done(function (res) {
                        layui.layer.close(load)
                        if (res.code == 1) {
                            layui.layer.msg(res.msg, {time: 1000, icon: 1});
                            document.getElementById('pwd').reset();
                        } else {
                            layui.layer.msg(res.msg, {time: 1000, icon: 2})
                        }
                    })
                )
            })
        })

	</script>
</body>
</html>